
/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2018原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.beans.factory.support;

import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.AliasRegistry;

/**
 * Interface for registries that hold bean definitions, for example RootBeanDefinition
 * and ChildBeanDefinition instances. Typically implemented by BeanFactories that
 * internally work with the AbstractBeanDefinition hierarchy.
 *
 * <p>This is the only interface in Spring's bean factory packages that encapsulates
 * <i>registration</i> of bean definitions. The standard BeanFactory interfaces
 * only cover access to a <i>fully configured factory instance</i>.
 *
 * <p>Spring's bean definition readers expect to work on an implementation of this
 * interface. Known implementors within the Spring core are DefaultListableBeanFactory
 * and GenericApplicationContext.
 *
 * @author Juergen Hoeller
 * @since 26.11.2003
 * @see org.springframework.beans.factory.config.BeanDefinition
 * @see AbstractBeanDefinition
 * @see RootBeanDefinition
 * @see ChildBeanDefinition
 * @see DefaultListableBeanFactory
 * @see org.springframework.context.support.GenericApplicationContext
 * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
 * @see PropertiesBeanDefinitionReader
 */
/**
 *保存bean定义的注册表的接口，例如RootBeanDefinition
 *和ChildBeanDefinition实例。通常由BeanFactories实现
 *内部使用AbstractBeanDefinition层次结构。
 *
 *＜p＞这是Spring的bean工厂包中唯一封装
 *＜i＞注册＜/i＞bean定义。标准BeanFactory接口
 *仅覆盖对<i>完全配置的工厂实例</i>的访问。
 *
 *＜p＞Spring的bean定义读者希望实现
 *接口。Spring核心中已知的实现者是DefaultListableBeanFactory
 *和GenericApplicationContext。
 *
 *@作者Juergen Hoeller
 *@自2003年11月26日
 *@参见org.springframework.beans.factory.config.BeanDefinition
 *@参见AbstractBeanDefinition
 *@参见RootBeanDefinition
 *@参见ChildBeanDefinition
 *@参见DefaultListableBeanFactory
 *@参见org.springframework.context.support.GenericApplicationContext
 *@参见org.springframework.beans.factory.xml.XmlBeanDefinitionReader
 *@参见PropertiesBeanDefinitionReader
 */
public interface BeanDefinitionRegistry extends AliasRegistry {

	/**
	 * Register a new bean definition with this registry.
	 * Must support RootBeanDefinition and ChildBeanDefinition.
	 * @param beanName the name of the bean instance to register
	 * @param beanDefinition definition of the bean instance to register
	 * @throws BeanDefinitionStoreException if the BeanDefinition is invalid
	 * @throws BeanDefinitionOverrideException if there is already a BeanDefinition
	 * for the specified bean name and we are not allowed to override it
	 * @see GenericBeanDefinition
	 * @see RootBeanDefinition
	 * @see ChildBeanDefinition
	 */
	/**
	 *向该注册表注册新的bean定义。
	 *必须支持RootBeanDefinition和ChildBeanDefinition。
	 *@param beanName要注册的bean实例的名称
	 *@param bean要注册的bean实例的定义
	 *如果BeanDefinition无效，@throws BeanDefinitionStoreException
	 *如果已经存在BeanDefinition，@throws BeanDefinitionOverrideException
	 *对于指定的bean名称，我们不允许重写它
	 *@参见GenericBeanDefinition
	 *@参见RootBeanDefinition
	 *@参见ChildBeanDefinition
	 */
	void registerBeanDefinition(String beanName, BeanDefinition beanDefinition)
			throws BeanDefinitionStoreException;

	/**
	 * Remove the BeanDefinition for the given name.
	 * @param beanName the name of the bean instance to register
	 * @throws NoSuchBeanDefinitionException if there is no such bean definition
	 */
	/**
	 *删除给定名称的BeanDefinition。
	 *@param beanName要注册的bean实例的名称
	 *如果没有这样的bean定义，@throws NoSuchBeanDefinitionException
	 */
	void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException;

	/**
	 * Return the BeanDefinition for the given bean name.
	 * @param beanName name of the bean to find a definition for
	 * @return the BeanDefinition for the given name (never {@code null})
	 * @throws NoSuchBeanDefinitionException if there is no such bean definition
	 */
	/**
	 *返回给定bean名称的BeanDefinition。
	 *@param beanName要查找其定义的bean的名称
	 *@return给定名称的BeanDefinition（从不｛@code null｝）
	 *如果没有这样的bean定义，@throws NoSuchBeanDefinitionException
	 */
	BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException;

	/**
	 * Check if this registry contains a bean definition with the given name.
	 * @param beanName the name of the bean to look for
	 * @return if this registry contains a bean definition with the given name
	 */
	/**
	 *检查此注册表是否包含具有给定名称的bean定义。
	 *@param beanName要查找的bean的名称
	 *@return如果此注册表包含具有给定名称的bean定义
	 */
	boolean containsBeanDefinition(String beanName);

	/**
	 * Return the names of all beans defined in this registry.
	 * @return the names of all beans defined in this registry,
	 * or an empty array if none defined
	 */
	/**
	 *返回此注册表中定义的所有bean的名称。
	 *@return此注册表中定义的所有bean的名称，
	 *或空数组（如果未定义）
	 */
	String[] getBeanDefinitionNames();

	/**
	 * Return the number of beans defined in the registry.
	 * @return the number of beans defined in the registry
	 */
	/**
	 *返回注册表中定义的bean数。
	 *@return注册表中定义的bean数
	 */
	int getBeanDefinitionCount();

	/**
	 * Determine whether the given bean name is already in use within this registry,
	 * i.e. whether there is a local bean or alias registered under this name.
	 * @param beanName the name to check
	 * @return whether the given bean name is already in use
	 */
	/**
	 *确定给定的bean名称是否已经在该注册表中使用，
	 *即是否存在以该名称注册的本地bean或别名。
	 *@param beanName要检查的名称
	 *@return给定的bean名称是否已在使用中
	 */
	boolean isBeanNameInUse(String beanName);

}
